package com.hongyun.tms.common.vo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hongyun.tms.common.annotation.excel.ExcelInfo;
import com.hongyun.tms.common.constants.CustomerTypeConstant;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDateTime;

import static com.hongyun.tms.common.constants.CustomerTypeConstant.*;

/**
 * customer 响应
 *
 * @author liPeng
 * @date 2024-05-31
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ExcelInfo(fileName = "客户信息导出")
public class MCustomerVO implements Serializable {

    @ApiModelProperty(value = "主键")
    @ExcelIgnore
    private Long id;

    @ApiModelProperty(value = "客户代码")
    @ExcelIgnore
    private String customerCode;

    @ApiModelProperty(value = "客户名称")
    @ExcelProperty(value = "客户名称", index = 0)
    private String customerName;


    @ApiModelProperty(value = "类型。1个人2企业。")
    @ExcelIgnore
    private Integer type;
    @ApiModelProperty(value = "类型。1个人2企业。")
    @ExcelProperty(value = "客户类型", index = 1)
    private String typeStr;

    @ApiModelProperty(value = "纳税人识别号")
    @ExcelProperty(value = "纳税人识别号", index = 2)
    private String tin;

    @ApiModelProperty(value = "身份证号")
    @ExcelProperty(value = "身份证号", index = 3)
    private String idNumber;

    @ApiModelProperty(value = "联系人姓名")
    @ExcelProperty(value = "联系人姓名", index = 4)
    private String contacts;

    @ApiModelProperty(value = "联系电话")
    @ExcelProperty(value = "联系电话", index = 5)
    private String tel;

    @ApiModelProperty(value = "联系地址")
    @ExcelProperty(value = "联系地址", index = 6)
    private String address;

    @ApiModelProperty(value = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ExcelIgnore
    private LocalDateTime createTime;

    @ApiModelProperty(value = "更新时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ExcelIgnore
    private LocalDateTime updateTime;

    public String getTypeStr() {
        if (type == null) {
            return UNKNOWN_DESC;
        }
        return type.equals(CustomerTypeConstant.PERSON) ? PERSON_DESC : ENTERPRISE_DESC;
    }
}

